//
//  ShiLiBaoGaoViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/5/5.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "ShiLiBaoGaoViewController.h"
#import "WaveTableViewCell.h"
#import "BiaoQianOnShiLiBaoGaoTableViewCell.h"
#import "TeBieZhuYiOnShiLiBaoGaoTableViewCell.h"
#import "YouYuChangRenOnShiLiBaoGaoTableViewCell.h"
#import "JianCeResultOnShiLiBaoGaoModel.h"
#import "ChanPinLeiBiaoGeTableViewCell.h"
#import "JianCeDiseaseModel.h"
#import "DanXiangDieaseViewController.h"
#import "ZongHeBaoGaoTableViewCell.h"

@interface ShiLiBaoGaoViewController ()<UITableViewDataSource, UITableViewDelegate, ChanPinLeiBiaoGeTableViewCellDelegate>



@property (nonatomic, strong) UITableView *shiLiBaoGaoTableview;

@property (nonatomic, strong) NSMutableArray *diseaseDataArray; // 疾病数据源
@property (nonatomic, strong) NSMutableArray *diseaseNameArray; // 疾病名字数组
@property (nonatomic, strong) NSMutableDictionary *isSelectDic; // 保存是否点击的字典


@end

@implementation ShiLiBaoGaoViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    // navi的修改
    [self changeNavigation];
    // 添加数据
    [self addData];
    // 布局
    [self addMySubview];
}

// navi的修改
- (void)changeNavigation
{
    self.navigationItem.title = @"示例报告";
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)addData
{
    // 构建模拟数据源，八大类
    // 心脑血管
    NSMutableArray *xinNaoXueGuanArray = [NSMutableArray arrayWithObjects:@{@"diseaseName":@"冠心病", @"fengXianZhishu":@"1.80", @"isUnLock": @"YES"},@{@"diseaseName":@"脑卒中", @"fengXianZhishu":@"3.51", @"isUnLock": @"YES"}, @{@"diseaseName":@"心肌梗死", @"fengXianZhishu":@"1.03", @"isUnLock": @"YES"}, @{@"diseaseName":@"高血压", @"fengXianZhishu":@"0.85", @"isUnLock": @"YES"}, @{@"diseaseName":@"R型糖尿病", @"fengXianZhishu":@"0.45", @"isUnLock": @"YES"}, @{@"diseaseName":@"高血脂症", @"fengXianZhishu":@"1.10", @"isUnLock":@"YES"}, @{@"diseaseName":@"房颤", @"fengXianZhishu":@"1.63", @"isUnLock":@"YES"}, @{@"diseaseName":@"静脉栓塞栓塞", @"fengXianZhishu":@"2.52", @"isUnLock": @"YES"}, nil];
    NSMutableArray *xinNaoXueGuanArray1 = [NSMutableArray array];
    for (int i = 0; i < xinNaoXueGuanArray.count; i++) {
        NSDictionary *tempDic = xinNaoXueGuanArray[i];
        NSMutableDictionary *resultDic = [NSMutableDictionary dictionaryWithDictionary:tempDic];
        [xinNaoXueGuanArray1 addObject:resultDic];
    }
    // 肿瘤
    NSMutableArray *zhongLiuArray = [NSMutableArray arrayWithObjects:@{@"diseaseName":@"肺癌", @"fengXianZhishu":@"4.11", @"isUnLock": @"YES"},@{@"diseaseName":@"胃癌", @"fengXianZhishu":@"1.44", @"isUnLock": @"YES"}, @{@"diseaseName":@"乳腺癌", @"fengXianZhishu":@"1.03", @"isUnLock": @"NO"}, @{@"diseaseName":@"结直肠癌", @"fengXianZhishu":@"0.85", @"isUnLock": @"NO"}, nil];
    NSMutableArray *zhongLiuArray1 = [NSMutableArray array];
    for (int i = 0; i < zhongLiuArray.count; i++) {
        NSDictionary *tempDic = zhongLiuArray[i];
        NSMutableDictionary *resultDic = [NSMutableDictionary dictionaryWithDictionary:tempDic];
        [zhongLiuArray1 addObject:resultDic];
    }
    // 遗传病
    NSMutableArray *yiChuanBingArray = [NSMutableArray arrayWithObjects:@{@"diseaseName":@"地中海贫血", @"fengXianZhishu":@"1.73", @"isUnLock": @"NO"},@{@"diseaseName":@"镰刀型贫血", @"fengXianZhishu":@"3.51", @"isUnLock": @"NO"}, @{@"diseaseName":@"遗传性耳聋", @"fengXianZhishu":@"1.03", @"isUnLock": @"NO"}, @{@"diseaseName":@"药物性耳聋", @"fengXianZhishu":@"0.85", @"isUnLock": @"NO"}, @{@"diseaseName":@"苯丙酮尿症", @"fengXianZhishu":@"0.45", @"isUnLock": @"NO"}, @{@"diseaseName":@"蚕豆症", @"fengXianZhishu":@"1.10", @"isUnLock":@"NO"}, @{@"diseaseName":@"渐冻症", @"fengXianZhishu":@"1.63", @"isUnLock":@"NO"}, @{@"diseaseName":@"白化病", @"fengXianZhishu":@"2.52", @"isUnLock": @"NO"}, nil];
    NSMutableArray *yiChuanBingArray1 = [NSMutableArray array];
    for (int i = 0; i < yiChuanBingArray.count; i++) {
        NSDictionary *tempDic = yiChuanBingArray[i];
        NSMutableDictionary *resultDic = [NSMutableDictionary dictionaryWithDictionary:tempDic];
        [yiChuanBingArray1 addObject:resultDic];
    }
    
    // 老年病
    NSMutableArray *laoNianArray = [NSMutableArray arrayWithObjects:@{@"diseaseName":@"老年痴呆", @"fengXianZhishu":@"1.73", @"isUnLock": @"NO"},@{@"diseaseName":@"帕金森", @"fengXianZhishu":@"3.51", @"isUnLock": @"NO"}, @{@"diseaseName":@"白内障", @"fengXianZhishu":@"1.03", @"isUnLock": @"NO"}, @{@"diseaseName":@"老年黄褐斑", @"fengXianZhishu":@"0.85", @"isUnLock": @"NO"}, nil];
    NSMutableArray *laoNianArray1 = [NSMutableArray array];
    for (int i = 0; i < laoNianArray.count; i++) {
        NSDictionary *tempDic = laoNianArray[i];
        NSMutableDictionary *resultDic = [NSMutableDictionary dictionaryWithDictionary:tempDic];
        [laoNianArray1 addObject:resultDic];
    }
    
    // 自身变异性疾病
    NSMutableArray *ziShenMianYiXingJiBingArray = [NSMutableArray arrayWithObjects:@{@"diseaseName":@"类风湿性关节炎", @"fengXianZhishu":@"1.73", @"isUnLock": @"NO"},@{@"diseaseName":@"强直性脊柱炎", @"fengXianZhishu":@"3.51", @"isUnLock": @"NO"}, @{@"diseaseName":@"系统性红斑狼疮", @"fengXianZhishu":@"1.03", @"isUnLock": @"NO"}, @{@"diseaseName":@"哮喘", @"fengXianZhishu":@"0.85", @"isUnLock": @"NO"}, @{@"diseaseName":@"过敏性鼻炎", @"fengXianZhishu":@"0.45", @"isUnLock": @"NO"}, @{@"diseaseName":@"痛风", @"fengXianZhishu":@"1.10", @"isUnLock":@"NO"}, nil];
    
    NSMutableArray *ziShenMianYiXingJiBingArray1 = [NSMutableArray array];
    for (int i = 0; i < ziShenMianYiXingJiBingArray.count; i++) {
        NSDictionary *tempDic = ziShenMianYiXingJiBingArray[i];
        NSMutableDictionary *resultDic = [NSMutableDictionary dictionaryWithDictionary:tempDic];
        [ziShenMianYiXingJiBingArray1 addObject:resultDic];
    }
    
    // 精神类疾病
    NSMutableArray *jingShenLeiJiBingArray = [NSMutableArray arrayWithObjects:@{@"diseaseName":@"抑郁症", @"fengXianZhishu":@"1.73", @"isUnLock": @"NO"},@{@"diseaseName":@"精神分裂症", @"fengXianZhishu":@"3.51", @"isUnLock": @"NO"}, @{@"diseaseName":@"强迫症", @"fengXianZhishu":@"1.03", @"isUnLock": @"NO"}, nil];
    
    NSMutableArray *jingShenLeiJiBingArray1 = [NSMutableArray array];
    for (int i = 0; i < jingShenLeiJiBingArray.count; i++) {
        NSDictionary *tempDic = jingShenLeiJiBingArray[i];
        NSMutableDictionary *resultDic = [NSMutableDictionary dictionaryWithDictionary:tempDic];
        [jingShenLeiJiBingArray1 addObject:resultDic];
    }
    
    // 营养代谢能力
    NSMutableArray *yingYangDaiXieNengLiArray = [NSMutableArray arrayWithObjects:@{@"diseaseName":@"叶酸", @"fengXianZhishu":@"1.73", @"isUnLock": @"NO"},@{@"diseaseName":@"酒精", @"fengXianZhishu":@"3.51", @"isUnLock": @"NO"}, @{@"diseaseName":@"抗空气污染能力", @"fengXianZhishu":@"1.03", @"isUnLock": @"NO"}, @{@"diseaseName":@"肥胖", @"fengXianZhishu":@"0.85", @"isUnLock": @"NO"}, @{@"diseaseName":@"性别决定", @"fengXianZhishu":@"0.85", @"isUnLock": @"NO"}, nil];
    
    NSMutableArray *yingYangDaiXieNengLiArray1 = [NSMutableArray array];
    for (int i = 0; i < yingYangDaiXieNengLiArray.count; i++) {
        NSDictionary *tempDic = yingYangDaiXieNengLiArray[i];
        NSMutableDictionary *resultDic = [NSMutableDictionary dictionaryWithDictionary:tempDic];
        [yingYangDaiXieNengLiArray1 addObject:resultDic];
    }
    // 个性天赋
    NSMutableArray *geXingTianFuArray = [NSMutableArray arrayWithObjects:@{@"diseaseName":@"语言天赋", @"fengXianZhishu":@"1.73", @"isUnLock": @"NO"},@{@"diseaseName":@"交际天赋", @"fengXianZhishu":@"3.51", @"isUnLock": @"NO"}, @{@"diseaseName":@"运动天赋", @"fengXianZhishu":@"1.03", @"isUnLock": @"NO"}, @{@"diseaseName":@"音乐天赋", @"fengXianZhishu":@"0.85", @"isUnLock": @"NO"}, @{@"diseaseName":@"身高", @"fengXianZhishu":@"0.45", @"isUnLock": @"NO"}, @{@"diseaseName":@"近视", @"fengXianZhishu":@"1.10", @"isUnLock":@"NO"}, @{@"diseaseName":@"多动症", @"fengXianZhishu":@"1.63", @"isUnLock":@"NO"}, @{@"diseaseName":@"肥胖症", @"fengXianZhishu":@"2.52", @"isUnLock": @"NO"}, nil];
    
    NSMutableArray *geXingTianFuArray1 = [NSMutableArray array];
    for (int i = 0; i < geXingTianFuArray.count; i++) {
        NSDictionary *tempDic = geXingTianFuArray[i];
        NSMutableDictionary *resultDic = [NSMutableDictionary dictionaryWithDictionary:tempDic];
        [geXingTianFuArray1 addObject:resultDic];
    }
    
    // 1代表完全解锁，2代表未完全解锁，3代表未解锁 DanXiangDataArray
    // 构建模拟数据
    NSArray *moniArray = [NSArray arrayWithObjects:@{@"diseaseName":@"心脑血管疾病", @"isWanQuanUnLock":@"1", @"DanXiangDataArray": xinNaoXueGuanArray1},@{@"diseaseName":@"肿瘤", @"isWanQuanUnLock":@"2", @"DanXiangDataArray":zhongLiuArray1}, @{@"diseaseName":@"遗传病", @"isWanQuanUnLock":@"3", @"DanXiangDataArray":yiChuanBingArray1}, @{@"diseaseName":@"老年病", @"isWanQuanUnLock":@"3", @"DanXiangDataArray":laoNianArray1}, @{@"diseaseName":@"自身免疫性疾病", @"isWanQuanUnLock":@"3", @"DanXiangDataArray":ziShenMianYiXingJiBingArray1}, @{@"diseaseName":@"精神类疾病", @"isWanQuanUnLock":@"3", @"DanXiangDataArray":jingShenLeiJiBingArray1}, @{@"diseaseName":@"营养代谢能力", @"isWanQuanUnLock":@"3", @"DanXiangDataArray":yingYangDaiXieNengLiArray1}, @{@"diseaseName":@"个性天赋", @"isWanQuanUnLock":@"3", @"DanXiangDataArray":geXingTianFuArray1},nil];
    self.diseaseDataArray = [NSMutableArray array];
    self.diseaseNameArray = [NSMutableArray array];
    self.isSelectDic = [NSMutableDictionary dictionary];
    for (NSDictionary *tempDic in moniArray) {
        JianCeDiseaseModel *model = [[JianCeDiseaseModel alloc] init];
        [model setValuesForKeysWithDictionary:tempDic];
        [self.diseaseDataArray addObject:model];
        [self.diseaseNameArray addObject:[tempDic valueForKey:@"diseaseName"]];
    }
    for (NSString *key in self.diseaseNameArray) {
        [self.isSelectDic setValue:@"NO" forKey:key];
    }
  
}

// 布局
- (void)addMySubview
{
    self.shiLiBaoGaoTableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64) style:UITableViewStylePlain];
    self.shiLiBaoGaoTableview.dataSource  = self;
    self.shiLiBaoGaoTableview.delegate = self;
    self.shiLiBaoGaoTableview.bounces = NO;
    self.shiLiBaoGaoTableview.showsVerticalScrollIndicator = NO;
    self.shiLiBaoGaoTableview.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_shiLiBaoGaoTableview];
    
    // 构建表尾
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 30 * kAdjustParamater)];
    footerView.backgroundColor = [UIColor whiteColor];
    self.shiLiBaoGaoTableview.tableFooterView = footerView;
}

#pragma mark - tableView代理
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
         return 4 + self.diseaseDataArray.count;
    }
    // 说明有综合报告
    return 5 + self.diseaseDataArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
        if (section <= 3) {
            return 1;
        } else {
            NSString *key = self.diseaseNameArray[section - 4];
            NSString *isSelect = [self.isSelectDic valueForKey:key];
            if ([isSelect isEqualToString:@"NO"]) {
                return 0;
            } else if ([isSelect isEqualToString:@"YES"]) {
                return 1;
            }
        }
        return 0;
    } else if (self.haveZongHeBaoGao == YES) {
        // 说明有综合报告
        if (section <= 4) {
            return 1;
        } else {
            NSString *key = self.diseaseNameArray[section - 5];
            NSString *isSelect = [self.isSelectDic valueForKey:key];
            if ([isSelect isEqualToString:@"NO"]) {
                return 0;
            } else if ([isSelect isEqualToString:@"YES"]) {
                return 1;
            }
        }
        return 0;
    }
    
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
        if (indexPath.section == 0) {
            // 示例报告
            static NSString *identifier = @"waveCell";
            WaveTableViewCell *waveCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (waveCell == nil) {
                waveCell = [[WaveTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            waveCell.selectionStyle = UITableViewCellSelectionStyleNone;
            return waveCell;
        } else if (indexPath.section == 1) {
            // 您的标签
            static NSString *identifier = @"woDeBiaoQianCell";
            BiaoQianOnShiLiBaoGaoTableViewCell *biaoQianCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (biaoQianCell == nil) {
                biaoQianCell = [[BiaoQianOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            biaoQianCell.selectionStyle = UITableViewCellSelectionStyleNone;
            biaoQianCell.biaoQianArray = [NSMutableArray arrayWithObjects:@"吸烟易上瘾", @"叶酸代谢能力差", @"钙吸收利用能力弱", @"近视风险高", @"冠心病风险高", @"强直性脊椎炎风险高", @"肥胖风险高", @"携带蚕豆病致病因子",@"脑卒中风险低",@"老年痴呆风险低",@"肺癌风险低",@"痛风风险低",@"抑郁症风险低",@"天生酒量王",@"音乐小王子",@"运动耐力强",@"高血压风险正常",@"白内障风险正常",@"类风湿性关节炎风险正常",@"无强迫症倾向",@"未携带地中海贫血致病因子",@"铁吸收能力一般",@"肌肉软骨组织受伤概率小", nil];
            return biaoQianCell;
        } else if (indexPath.section == 2) {
            // 特别注意
            static NSString *identifier = @"teBieZhuYi";
            TeBieZhuYiOnShiLiBaoGaoTableViewCell *teBieCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (teBieCell == nil) {
                teBieCell = [[TeBieZhuYiOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            teBieCell.selectionStyle = UITableViewCellSelectionStyleNone;
            teBieCell.teBieZhuYiArray = [NSMutableArray arrayWithObjects:@"吸烟易上瘾", @"叶酸代谢能力差", @"钙吸收利用能力弱", @"近视风险高", @"冠心病风险高", @"强直性脊椎炎风险高", @"肥胖风险高", @"携带蚕豆病致病因子", @"勤洗澡", nil];
            return teBieCell;
        } else if (indexPath.section == 3) {
            // 优于常人
            static NSString *identifier = @"youYuChangRen";
            YouYuChangRenOnShiLiBaoGaoTableViewCell *youYuCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (youYuCell == nil) {
                youYuCell = [[YouYuChangRenOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            youYuCell.selectionStyle = UITableViewCellSelectionStyleNone;
            youYuCell.youYuChangRenArray = [NSMutableArray arrayWithObjects:@"脑卒中风险低", @"老年痴呆风险低", @"肺癌风险低", @"痛风风险低", @"抑郁症风险低", @"天生酒量王", @"音乐小王子", @"运动耐力强", nil];
            return youYuCell;
        } else  {
            static NSString *identifier = @"chanPin";
            if (self.diseaseDataArray.count > (indexPath.section - 4)) {
                // 获取model
                JianCeDiseaseModel *model = self.diseaseDataArray[indexPath.section - 4];
                
                // chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
                ChanPinLeiBiaoGeTableViewCell *chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier withDataArray:[model valueForKey:@"DanXiangDataArray"] withIndexPath:indexPath];
                
                chanPinCell.delegate = self;
                //  chanPinCell.selectionStyle = UITableViewCellSelectionStyleNone;
                return chanPinCell;
            }
        }
        return nil;
    } else if (self.haveZongHeBaoGao == YES) {
        // 说明有综合报告
        if (indexPath.section == 0) {
            // 示例报告
            static NSString *identifier = @"waveCell";
            WaveTableViewCell *waveCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (waveCell == nil) {
                waveCell = [[WaveTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            waveCell.selectionStyle = UITableViewCellSelectionStyleNone;
            return waveCell;
        } else if (indexPath.section == 1) {
            // 综合报告
            static NSString *identifier = @"zongHeBaoGaoCell";
            ZongHeBaoGaoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (cell == nil) {
                cell = [[ZongHeBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        } else if (indexPath.section == 2) {
            // 您的标签
            static NSString *identifier = @"woDeBiaoQianCell";
            BiaoQianOnShiLiBaoGaoTableViewCell *biaoQianCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (biaoQianCell == nil) {
                biaoQianCell = [[BiaoQianOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            biaoQianCell.selectionStyle = UITableViewCellSelectionStyleNone;
            biaoQianCell.biaoQianArray = [NSMutableArray arrayWithObjects:@"张国文", @"林俊杰", @"周杰伦", @"王力宏", @"陶喆", @"taylorswift", @"凯莉布鲁克", nil];
            return biaoQianCell;
        } else if (indexPath.section == 3) {
            // 特别注意
            static NSString *identifier = @"teBieZhuYi";
            TeBieZhuYiOnShiLiBaoGaoTableViewCell *teBieCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (teBieCell == nil) {
                teBieCell = [[TeBieZhuYiOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            teBieCell.selectionStyle = UITableViewCellSelectionStyleNone;
            teBieCell.teBieZhuYiArray = [NSMutableArray arrayWithObjects:@"张国文张国文", @"张国文", @"张国文张", @"张国文张国", @"张国文张国文", @"张", @"国", @"张国文张国文", @"国文", nil];
            return teBieCell;
        } else if (indexPath.section == 4) {
            // 优于常人
            static NSString *identifier = @"youYuChangRen";
            YouYuChangRenOnShiLiBaoGaoTableViewCell *youYuCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (youYuCell == nil) {
                youYuCell = [[YouYuChangRenOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            youYuCell.selectionStyle = UITableViewCellSelectionStyleNone;
            youYuCell.youYuChangRenArray = [NSMutableArray arrayWithObjects:@"张国文张国文", @"张国文", @"张国文张", @"张国文张国", @"张国文张国文", @"张", @"国", @"张国文张国文", @"国文", nil];
            return youYuCell;
        } else  {
            static NSString *identifier = @"chanPin";
            
            if (self.diseaseDataArray.count > (indexPath.section - 5)) {
                // 获取model
                JianCeDiseaseModel *model = self.diseaseDataArray[indexPath.section - 5];
               
                    // chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
                    ChanPinLeiBiaoGeTableViewCell *chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier withDataArray:[model valueForKey:@"DanXiangDataArray"] withIndexPath:indexPath];
                
                chanPinCell.delegate = self;
                //  chanPinCell.selectionStyle = UITableViewCellSelectionStyleNone;
                return chanPinCell;
            }
            
        }
        return nil;
    }
   // 没有情况
    return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (self.haveZongHeBaoGao == NO) {
        // 没有综合报告
        if (section == 0) {
            // 示例报告
            UIView *shiLiBaoGaoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            shiLiBaoGaoView.backgroundColor = [UIColor whiteColor];
            UILabel *shiLiBaoGaoImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            shiLiBaoGaoImageV.backgroundColor = kCyanColor;
            shiLiBaoGaoImageV.layer.cornerRadius = 3 * kAdjustParamater;
            shiLiBaoGaoImageV.layer.masksToBounds = YES;
            [shiLiBaoGaoView addSubview:shiLiBaoGaoImageV];
            
            // 示例报告标题
            UILabel *shiLiBaoGaoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(shiLiBaoGaoImageV.right + 10 * kAdjustParamater, shiLiBaoGaoImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   shiLiBaoGaoTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            shiLiBaoGaoTitleLabel.text = @"这是一份示例报告";
            shiLiBaoGaoTitleLabel.textAlignment = NSTextAlignmentLeft;
            shiLiBaoGaoTitleLabel.textColor = [UIColor blackColor];
            shiLiBaoGaoTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [shiLiBaoGaoView addSubview:shiLiBaoGaoTitleLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnShiLiBaoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, shiLiBaoGaoImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnShiLiBaoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [shiLiBaoGaoView addSubview:grayLineOnShiLiBaoBottom];
            
            return shiLiBaoGaoView;
        } else if (section == 1) {
            // 您的标签
            UIView *biaoQianView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            biaoQianView.backgroundColor = [UIColor whiteColor];
            UILabel *biaoQianImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            biaoQianImageV.backgroundColor = [UIColor colorWithRed:166 / 255.0 green:208 / 255.0 blue:107 / 255.0 alpha:1];
            biaoQianImageV.layer.cornerRadius = 3 * kAdjustParamater;
            biaoQianImageV.layer.masksToBounds = YES;
            [biaoQianView addSubview:biaoQianImageV];
            
            // 您的标签标题
            UILabel *biaoQianTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(biaoQianImageV.right + 10 * kAdjustParamater, biaoQianImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            biaoQianTitleLabel.text = @"您的标签";
            biaoQianTitleLabel.textAlignment = NSTextAlignmentLeft;
            biaoQianTitleLabel.textColor = [UIColor blackColor];
            biaoQianTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [biaoQianView addSubview:biaoQianTitleLabel];
            // 您的标签下方的灰色条
            UILabel *grayLineOnBiaoQianBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, biaoQianImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnBiaoQianBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [biaoQianView addSubview:grayLineOnBiaoQianBottom];
            
            return biaoQianView;
            
        } else if (section == 2) {
            // 特别注意
            UIView *teBieZhuYiView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            teBieZhuYiView.backgroundColor = [UIColor whiteColor];
            UILabel *teBieZhuYiImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            teBieZhuYiImageV.backgroundColor = kYellowColor;
            teBieZhuYiImageV.layer.cornerRadius = 3 * kAdjustParamater;
            teBieZhuYiImageV.layer.masksToBounds = YES;
            [teBieZhuYiView addSubview:teBieZhuYiImageV];
            
            // 特别注意标题
            UILabel *teBieZhuYiLabel = [[UILabel alloc] initWithFrame:CGRectMake(teBieZhuYiImageV.right + 10 * kAdjustParamater, teBieZhuYiImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            teBieZhuYiLabel.text = @"特别注意";
            teBieZhuYiLabel.textAlignment = NSTextAlignmentLeft;
            teBieZhuYiLabel.textColor = [UIColor blackColor];
            teBieZhuYiLabel.font = [UIFont systemFontOfSize:k17Big];
            [teBieZhuYiView addSubview:teBieZhuYiLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnTeBieZhuYiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, teBieZhuYiImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnTeBieZhuYiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [teBieZhuYiView addSubview:grayLineOnTeBieZhuYiBottom];
            
            return teBieZhuYiView;
        } else if (section == 3) {
            // 优于常人
            UIView *youYuChangRenView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            youYuChangRenView.backgroundColor = [UIColor whiteColor];
            UILabel *youYuChangRenImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            youYuChangRenImageV.backgroundColor = [UIColor colorWithRed:138 / 255.0 green:208 / 255.0 blue:212 / 255.0 alpha:1];
            youYuChangRenImageV.layer.cornerRadius = 3 * kAdjustParamater;
            youYuChangRenImageV.layer.masksToBounds = YES;
            [youYuChangRenView addSubview:youYuChangRenImageV];
            
            // 优于常人标题
            UILabel *youYuChangRenLabel = [[UILabel alloc] initWithFrame:CGRectMake(youYuChangRenImageV.right + 10 * kAdjustParamater, youYuChangRenImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            youYuChangRenLabel.text = @"优于常人";
            youYuChangRenLabel.textAlignment = NSTextAlignmentLeft;
            youYuChangRenLabel.textColor = [UIColor blackColor];
            youYuChangRenLabel.font = [UIFont systemFontOfSize:k17Big];
            [youYuChangRenView addSubview:youYuChangRenLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnYouYuChangRenBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, youYuChangRenImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnYouYuChangRenBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [youYuChangRenView addSubview:grayLineOnYouYuChangRenBottom];
            
            return youYuChangRenView;
        } else  {
            UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61 * kAdjustParamater)];
            tempView.backgroundColor = [UIColor whiteColor];
            tempView.tag = 400 + section;
            // 疾病名字
            UILabel *diseaseNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(25 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            JianCeDiseaseModel *tempModel = self.diseaseDataArray[section - 4];
            diseaseNameLabel.text = [tempModel valueForKey:@"diseaseName"];
            diseaseNameLabel.textColor = [UIColor blackColor];
            diseaseNameLabel.font = [UIFont systemFontOfSize:k17Big];
            [tempView addSubview:diseaseNameLabel];
            CGRect newDiseaseNameFrame = diseaseNameLabel.frame;
            newDiseaseNameFrame.size.width = [[NetStatusHandle shareHandle] adjustWidth:diseaseNameLabel.text size:17 height:20];
            diseaseNameLabel.frame = newDiseaseNameFrame;
            // 疾病是否已经解锁
            UIImageView *isUnlockImageV = [[UIImageView alloc] initWithFrame:CGRectMake(diseaseNameLabel.right + 10 * kAdjustParamater, diseaseNameLabel.top + 3 * kAdjustParamater, 15 * kAdjustParamater, 15 * kAdjustParamater)];
            NSString *isUnlockString = [tempModel valueForKey:@"isWanQuanUnLock"];
         //   NSLog(@"isUnlockString = %@", isUnlockString);
            if ([isUnlockString isEqualToString:@"1"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWanQuanJieSuo-shilibaogao"];
            } else if ([isUnlockString isEqualToString:@"2"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWeiWanQuanJieSuo-shilibaogao"];
            } else if ([isUnlockString isEqualToString:@"3"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWeiJieSuo-shilibaogao"];
            }
            [tempView addSubview:isUnlockImageV];
            
            // 是否已经解锁的标题
            UILabel *isUnlockLabel = [[UILabel alloc] initWithFrame:CGRectMake(isUnlockImageV.right + 10 * kAdjustParamater, diseaseNameLabel.top, 220 * kAdjustParamater, 20 * kAdjustParamater)];
            //    isUnlockLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            
            isUnlockLabel.textAlignment = NSTextAlignmentLeft;
            [tempView addSubview:isUnlockLabel];
            if ([isUnlockString isEqualToString:@"1"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"已完全解码";
                isUnlockLabel.textColor = kCyanColor;
            } else if ([isUnlockString isEqualToString:@"2"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"未完全解码";
                isUnlockLabel.textColor = kCyanColor;
                //                isUnlockLabel.text = @"立即解码";
                //                isUnlockLabel.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
                //                // 不同的子图大小
                //                NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"立即解码 【本次解码需要10积分】"];
                //                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:k15Big] range:NSMakeRange(0, 4)];
                //                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:k13Big] range:NSMakeRange(5, 12)];
                //                [isUnlockLabel setAttributedText:str];
            } else if ([isUnlockString isEqualToString:@"3"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"未解码";
                isUnlockLabel.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
            }
            // 自适应宽度
            CGRect unlockLabelFrame = isUnlockLabel.frame;
            unlockLabelFrame.size.width = [[NetStatusHandle shareHandle] adjustWidth:isUnlockLabel.text size:15 height:20];
            isUnlockLabel.frame = unlockLabelFrame;
            
            UIImageView *jianTouImageV = [[UIImageView alloc] initWithFrame:CGRectMake(340 * kAdjustParamater, 17 * kAdjustParamater, 25 * kAdjustParamater, 25 * kAdjustParamater)];
            NSString *key = self.diseaseNameArray[section - 4];
            NSString *isSelect = [self.isSelectDic valueForKey:key];
            
            if ([isSelect isEqualToString:@"YES"]) {
                jianTouImageV.image = [UIImage imageNamed:@"cyanjiantou-createGroup"];
            } else if ([isSelect isEqualToString:@"NO"]) {
                jianTouImageV.image = [UIImage imageNamed:@"huisejiantou-createGroup"];
            }
            [tempView addSubview:jianTouImageV];
            
            UITapGestureRecognizer *selectTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectWhat:)];
            [tempView addGestureRecognizer:selectTapGes];
            
            UILabel *grayLineOnBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, 60 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [tempView addSubview:grayLineOnBottom];
            
            return tempView;
        }
        return nil;
    } else if (self.haveZongHeBaoGao == YES) {
        // 有综合报告
        if (section == 0) {
            // 示例报告
            UIView *shiLiBaoGaoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            shiLiBaoGaoView.backgroundColor = [UIColor whiteColor];
            UILabel *shiLiBaoGaoImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            shiLiBaoGaoImageV.backgroundColor = kCyanColor;
            shiLiBaoGaoImageV.layer.cornerRadius = 3 * kAdjustParamater;
            shiLiBaoGaoImageV.layer.masksToBounds = YES;
            [shiLiBaoGaoView addSubview:shiLiBaoGaoImageV];
            
            // 示例报告标题
            UILabel *shiLiBaoGaoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(shiLiBaoGaoImageV.right + 10 * kAdjustParamater, shiLiBaoGaoImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   shiLiBaoGaoTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            shiLiBaoGaoTitleLabel.text = @"这是一份示例报告";
            shiLiBaoGaoTitleLabel.textAlignment = NSTextAlignmentLeft;
            shiLiBaoGaoTitleLabel.textColor = [UIColor blackColor];
            shiLiBaoGaoTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [shiLiBaoGaoView addSubview:shiLiBaoGaoTitleLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnShiLiBaoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, shiLiBaoGaoImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnShiLiBaoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [shiLiBaoGaoView addSubview:grayLineOnShiLiBaoBottom];
            
            return shiLiBaoGaoView;
        } else if (section == 1) {
            // 综合报告
            UIView *zongHeBaoGaoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            zongHeBaoGaoView.backgroundColor = [UIColor whiteColor];
            UILabel *zongHeBaoGaoImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            zongHeBaoGaoImageV.backgroundColor = [UIColor purpleColor];
            zongHeBaoGaoImageV.layer.cornerRadius = 3 * kAdjustParamater;
            zongHeBaoGaoImageV.layer.masksToBounds = YES;
            [zongHeBaoGaoView addSubview:zongHeBaoGaoImageV];
            
            // 综合报告标题
            UILabel *zongHeBaoGaoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(zongHeBaoGaoImageV.right + 10 * kAdjustParamater, zongHeBaoGaoImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   shiLiBaoGaoTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            zongHeBaoGaoTitleLabel.text = @"综合报告内容";
            zongHeBaoGaoTitleLabel.textAlignment = NSTextAlignmentLeft;
            zongHeBaoGaoTitleLabel.textColor = [UIColor blackColor];
            zongHeBaoGaoTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [zongHeBaoGaoView addSubview:zongHeBaoGaoTitleLabel];
            // 综合报告下方的灰色条
            UILabel *grayLineOnShiLiBaoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, zongHeBaoGaoImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnShiLiBaoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [zongHeBaoGaoView addSubview:grayLineOnShiLiBaoBottom];
            
            return zongHeBaoGaoView;
        } else if (section == 2) {
            // 您的标签
            UIView *biaoQianView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            biaoQianView.backgroundColor = [UIColor whiteColor];
            UILabel *biaoQianImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            biaoQianImageV.backgroundColor = [UIColor colorWithRed:166 / 255.0 green:208 / 255.0 blue:107 / 255.0 alpha:1];
            biaoQianImageV.layer.cornerRadius = 3 * kAdjustParamater;
            biaoQianImageV.layer.masksToBounds = YES;
            [biaoQianView addSubview:biaoQianImageV];
            
            // 您的标签标题
            UILabel *biaoQianTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(biaoQianImageV.right + 10 * kAdjustParamater, biaoQianImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            biaoQianTitleLabel.text = @"您的标签";
            biaoQianTitleLabel.textAlignment = NSTextAlignmentLeft;
            biaoQianTitleLabel.textColor = [UIColor blackColor];
            biaoQianTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [biaoQianView addSubview:biaoQianTitleLabel];
            // 您的标签下方的灰色条
            UILabel *grayLineOnBiaoQianBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, biaoQianImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnBiaoQianBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [biaoQianView addSubview:grayLineOnBiaoQianBottom];
            
            return biaoQianView;
            
        } else if (section == 3) {
            // 特别注意
            UIView *teBieZhuYiView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            teBieZhuYiView.backgroundColor = [UIColor whiteColor];
            UILabel *teBieZhuYiImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            teBieZhuYiImageV.backgroundColor = kYellowColor;
            teBieZhuYiImageV.layer.cornerRadius = 3 * kAdjustParamater;
            teBieZhuYiImageV.layer.masksToBounds = YES;
            [teBieZhuYiView addSubview:teBieZhuYiImageV];
            
            // 特别注意标题
            UILabel *teBieZhuYiLabel = [[UILabel alloc] initWithFrame:CGRectMake(teBieZhuYiImageV.right + 10 * kAdjustParamater, teBieZhuYiImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            teBieZhuYiLabel.text = @"特别注意";
            teBieZhuYiLabel.textAlignment = NSTextAlignmentLeft;
            teBieZhuYiLabel.textColor = [UIColor blackColor];
            teBieZhuYiLabel.font = [UIFont systemFontOfSize:k17Big];
            [teBieZhuYiView addSubview:teBieZhuYiLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnTeBieZhuYiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, teBieZhuYiImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnTeBieZhuYiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [teBieZhuYiView addSubview:grayLineOnTeBieZhuYiBottom];
            
            return teBieZhuYiView;
        } else if (section == 4) {
            // 优于常人
            UIView *youYuChangRenView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            youYuChangRenView.backgroundColor = [UIColor whiteColor];
            UILabel *youYuChangRenImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            youYuChangRenImageV.backgroundColor = [UIColor colorWithRed:138 / 255.0 green:208 / 255.0 blue:212 / 255.0 alpha:1];
            youYuChangRenImageV.layer.cornerRadius = 3 * kAdjustParamater;
            youYuChangRenImageV.layer.masksToBounds = YES;
            [youYuChangRenView addSubview:youYuChangRenImageV];
            
            // 优于常人标题
            UILabel *youYuChangRenLabel = [[UILabel alloc] initWithFrame:CGRectMake(youYuChangRenImageV.right + 10 * kAdjustParamater, youYuChangRenImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            youYuChangRenLabel.text = @"优于常人";
            youYuChangRenLabel.textAlignment = NSTextAlignmentLeft;
            youYuChangRenLabel.textColor = [UIColor blackColor];
            youYuChangRenLabel.font = [UIFont systemFontOfSize:k17Big];
            [youYuChangRenView addSubview:youYuChangRenLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnYouYuChangRenBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, youYuChangRenImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnYouYuChangRenBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [youYuChangRenView addSubview:grayLineOnYouYuChangRenBottom];
            
            return youYuChangRenView;
        } else  {
            UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61 * kAdjustParamater)];
            tempView.backgroundColor = [UIColor whiteColor];
            tempView.tag = 400 + section;
            // 疾病名字
            UILabel *diseaseNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(25 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            JianCeDiseaseModel *tempModel = self.diseaseDataArray[section - 5];
            diseaseNameLabel.text = [tempModel valueForKey:@"diseaseName"];
            diseaseNameLabel.textColor = [UIColor blackColor];
            diseaseNameLabel.font = [UIFont systemFontOfSize:k17Big];
            [tempView addSubview:diseaseNameLabel];
            CGRect newDiseaseNameFrame = diseaseNameLabel.frame;
            newDiseaseNameFrame.size.width = [[NetStatusHandle shareHandle] adjustWidth:diseaseNameLabel.text size:17 height:20];
            diseaseNameLabel.frame = newDiseaseNameFrame;
            // 疾病是否已经解锁
            UIImageView *isUnlockImageV = [[UIImageView alloc] initWithFrame:CGRectMake(diseaseNameLabel.right + 10 * kAdjustParamater, diseaseNameLabel.top + 3 * kAdjustParamater, 15 * kAdjustParamater, 15 * kAdjustParamater)];
            NSString *isUnlockString = [tempModel valueForKey:@"isWanQuanUnLock"];
            NSLog(@"isUnlockString = %@", isUnlockString);
            if ([isUnlockString isEqualToString:@"1"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWanQuanJieSuo-shilibaogao"];
            } else if ([isUnlockString isEqualToString:@"2"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWeiWanQuanJieSuo-shilibaogao"];
            } else if ([isUnlockString isEqualToString:@"3"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWeiJieSuo-shilibaogao"];
            }
            [tempView addSubview:isUnlockImageV];
            
            // 是否已经解锁的标题
            UILabel *isUnlockLabel = [[UILabel alloc] initWithFrame:CGRectMake(isUnlockImageV.right + 10 * kAdjustParamater, diseaseNameLabel.top, 220 * kAdjustParamater, 20 * kAdjustParamater)];
            //    isUnlockLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            
            isUnlockLabel.textAlignment = NSTextAlignmentLeft;
            [tempView addSubview:isUnlockLabel];
            if ([isUnlockString isEqualToString:@"1"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"已完全解码";
                isUnlockLabel.textColor = kCyanColor;
            } else if ([isUnlockString isEqualToString:@"2"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"未完全解码";
                isUnlockLabel.textColor = kCyanColor;
//                isUnlockLabel.text = @"立即解码";
//                isUnlockLabel.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
//                // 不同的子图大小
//                NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"立即解码 【本次解码需要10积分】"];
//                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:k15Big] range:NSMakeRange(0, 4)];
//                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:k13Big] range:NSMakeRange(5, 12)];
//                [isUnlockLabel setAttributedText:str];
            } else if ([isUnlockString isEqualToString:@"3"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"未解码";
                isUnlockLabel.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
            }
            // 自适应宽度
            CGRect unlockLabelFrame = isUnlockLabel.frame;
            unlockLabelFrame.size.width = [[NetStatusHandle shareHandle] adjustWidth:isUnlockLabel.text size:15 height:20];
            isUnlockLabel.frame = unlockLabelFrame;
            
            UIImageView *jianTouImageV = [[UIImageView alloc] initWithFrame:CGRectMake(340 * kAdjustParamater, 17 * kAdjustParamater, 25 * kAdjustParamater, 25 * kAdjustParamater)];
            NSString *key = self.diseaseNameArray[section - 5];
            NSString *isSelect = [self.isSelectDic valueForKey:key];
            
            if ([isSelect isEqualToString:@"YES"]) {
                jianTouImageV.image = [UIImage imageNamed:@"cyanjiantou-createGroup"];
            } else if ([isSelect isEqualToString:@"NO"]) {
                jianTouImageV.image = [UIImage imageNamed:@"huisejiantou-createGroup"];
            }
            [tempView addSubview:jianTouImageV];
            
            UITapGestureRecognizer *selectTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectWhat:)];
            [tempView addGestureRecognizer:selectTapGes];
            
            UILabel *grayLineOnBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, 60 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [tempView addSubview:grayLineOnBottom];
            
            return tempView;
        }
        return nil;
    }
    // 没有这种情况
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
        if (indexPath.section == 0) {
            return 330 * kAdjustParamater;
        } else if (indexPath.section == 1) {
            return 290 * kAdjustParamater;
        } else if (indexPath.section == 2) {
            // 特别注意自适应高度
            TeBieZhuYiOnShiLiBaoGaoTableViewCell *teBieCell = (TeBieZhuYiOnShiLiBaoGaoTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return teBieCell.grayLineOnBottom.bottom;
        } else if (indexPath.section == 3) {
            // 优于常人自适应高度
            YouYuChangRenOnShiLiBaoGaoTableViewCell *youYuCell = (YouYuChangRenOnShiLiBaoGaoTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return youYuCell.grayLineOnBottom.bottom;
        } else {
            // 自适应高度
            ChanPinLeiBiaoGeTableViewCell *tempCell = (ChanPinLeiBiaoGeTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return tempCell.myBiaoGe.bottom + 130 * kAdjustParamater;
        }
        return 0;
    } else if (self.haveZongHeBaoGao == YES) {
        // 说明有综合报告
        if (indexPath.section == 0) {
            return 330 * kAdjustParamater;
        } else if (indexPath.section == 1) {
            // 真实数据的话需要更改高度，自适应
            return 400 * kAdjustParamater;
        } else if (indexPath.section == 2) {
            return 290 * kAdjustParamater;
        } else if (indexPath.section == 3) {
            // 特别注意自适应高度
            TeBieZhuYiOnShiLiBaoGaoTableViewCell *teBieCell = (TeBieZhuYiOnShiLiBaoGaoTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return teBieCell.grayLineOnBottom.bottom;
        } else if (indexPath.section == 4) {
            
        } else {
            // 自适应高度
            ChanPinLeiBiaoGeTableViewCell *tempCell = (ChanPinLeiBiaoGeTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return tempCell.myBiaoGe.bottom + 130 * kAdjustParamater;
        }
        return 0;
    }
   // 没有这种情况
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 61 * kAdjustParamater;
}





#pragma mark - 点击选择
- (void)selectWhat:(UITapGestureRecognizer *)tapGes
{
    
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
 
        
        // 已经解锁
        NSString *key = self.diseaseNameArray[tapGes.view.tag - 404];
        NSString *isSelect = [self.isSelectDic valueForKey:key];
        if ([isSelect isEqualToString:@"NO"]) {
            [self.isSelectDic setValue:@"YES" forKey:key];
        } else if ([isSelect isEqualToString:@"YES"]) {
            [self.isSelectDic setValue:@"NO" forKey:key];
        }
        [self.shiLiBaoGaoTableview reloadData];

    } else if (self.haveZongHeBaoGao == YES) {
        NSString *key = self.diseaseNameArray[tapGes.view.tag - 405];
        NSString *isSelect = [self.isSelectDic valueForKey:key];
        if ([isSelect isEqualToString:@"NO"]) {
            [self.isSelectDic setValue:@"YES" forKey:key];
        } else if ([isSelect isEqualToString:@"YES"]) {
            [self.isSelectDic setValue:@"NO" forKey:key];
        }
        [self.shiLiBaoGaoTableview reloadData];
//        // 说明有综合报告

    }
    
}

#warning 点击表格的回调
- (void)clickWhatRowCell:(NSInteger)row isUnLock:(NSString *)isUnLock cellIndexPath:(NSIndexPath *)indexPath
{
    if (self.haveZongHeBaoGao == NO) {
        NSLog(@"第%ld个表格,第%ld行,解锁状态:%@", indexPath.section - 4, row, isUnLock);
        if ([isUnLock isEqualToString:@"YES"]) {
            NSLog(@"已经解锁");
            DanXiangDieaseViewController *danXiangDieaseVC = [[DanXiangDieaseViewController alloc] init];
            [self.navigationController pushViewController:danXiangDieaseVC animated:YES];
        } else if ([isUnLock isEqualToString:@"NO"]) {
            [self addJieSuoAlertWithCellSection:(indexPath.section - 4)  AndDiseaseRow:row];
        }
    } else if (self.haveZongHeBaoGao == YES) {
        NSLog(@"第%ld个表格,第%ld行,解锁状态:%@", indexPath.section - 5, row, isUnLock);
       
        if ([isUnLock isEqualToString:@"YES"]) {
            NSLog(@"已经解锁");
            DanXiangDieaseViewController *danXiangDieaseVC = [[DanXiangDieaseViewController alloc] init];
            [self.navigationController pushViewController:danXiangDieaseVC animated:YES];
        } else if ([isUnLock isEqualToString:@"NO"]) {
            [self addJieSuoAlertWithCellSection:(indexPath.section - 5)  AndDiseaseRow:row];
        }
    }
    

   
}

- (void)addJieSuoAlertWithCellSection:(NSInteger)section AndDiseaseRow:(NSInteger)row
{
    // 未解锁
                UIAlertController *alertV = [UIAlertController alertControllerWithTitle:@"提醒" message:@"该疾病未解锁，解锁需要花费10积分，您确定要解锁么" preferredStyle:UIAlertControllerStyleAlert];
                // 修改标题颜色
                NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:@"提醒"];
                [titleString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)];
                [titleString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 2)];
                [alertV setValue:titleString forKey:@"attributedTitle"];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                    NSLog(@"取消");
                }];
                [alertV addAction:cancelAction];
                UIAlertAction *queDingAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                    NSLog(@"确定解锁");
                    // 获取model
                    JianCeDiseaseModel *tempModel = self.diseaseDataArray[section];
                    NSMutableArray *diseaseDanXiangArray = [tempModel valueForKey:@"DanXiangDataArray"];
                    NSDictionary *tempDic = diseaseDanXiangArray[row];
                    NSLog(@"tempDic = %@", tempDic);
                    
                    [tempDic setValue:@"YES" forKey:@"isUnLock"];
                    // 刷新界面
                    [self.shiLiBaoGaoTableview reloadData];
                    // 判断该类下是否全部开启
                    JianCeDiseaseModel *tempModel1 = self.diseaseDataArray[section];
                     NSMutableArray *diseaseDanXiangArray1 = [tempModel1 valueForKey:@"DanXiangDataArray"];
                    int result = 1; // 默认为需要打开解锁
                    int jieMaNumber = 0;
                    for (int i = 0; i < diseaseDanXiangArray1.count; i++) {
                        NSDictionary *tempDic = diseaseDanXiangArray1[i];
                        NSString *isUnLock = [tempDic valueForKey:@"isUnLock"];
                        int j = 0;
                        if ([isUnLock isEqualToString:@"YES"]) {
                            j = 1;
                            jieMaNumber++;
                        } else if ([isUnLock isEqualToString:@"NO"]) {
                            j = 0;
                        }
                        result = result * j;
                    }
                    if (jieMaNumber > diseaseDanXiangArray1.count / 2) {
                        tempModel1.isWanQuanUnLock = @"2";
                        [self.shiLiBaoGaoTableview reloadData];
                    }
                    if (result == 1) {
                        // 说明已经全部解开
                        tempModel1.isWanQuanUnLock = @"1";
                        [self.shiLiBaoGaoTableview reloadData];
                    } else {
                        // 说明没有全部解开
                    }
                }];
                [alertV addAction:queDingAction];
                [self presentViewController:alertV animated:YES completion:nil];
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
